package com.corona.game;

import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.graphics.Texture;
import com.badlogic.gdx.graphics.g2d.Sprite;
import com.corona.Game;
import com.corona.game.util.TextureCache;

/* compiled from: Menu.java */
/* loaded from: pokewilds.jar:com/pkmngen/game/DrawText.class */
public class DrawText extends Menu {
    String text;
    Texture texture = TextureCache.get(Gdx.files.internal("textbox_bg1.png"));

    @Override // com.corona.game.Action
    public String getCamera() {
        return "gui";
    }

    @Override // com.corona.game.Action
    public Action.Layer getLayer() {
        return Action.Layer.gui_106;
    }

    public DrawText(String text) {
        this.text = null;
        this.text = text;
    }

    @Override // com.corona.game.Action
    public void step(Game game) {
        if (this.goAway) {
            game.actionStack.remove(this);
        } else if (this.text != null) {
            game.uiBatch.draw(this.texture, 0.0f, 0.0f);
            int i = 0;
            int j = 0;
            char[] characters = this.text.toCharArray();
            int k = 0;
            while (k < characters.length) {
                char character = characters[k];
                if (character == ' ' && k + 1 < characters.length) {
                    int length = 1;
                    for (char nextChar = characters[k + 1]; nextChar != ' ' && k + length < characters.length; nextChar = characters[k + length]) {
                        length++;
                    }
                    if (i + length > 20 && j < 5) {
                        i = -1;
                        j++;
                    }
                }
                Sprite letterSprite = game.textDict.get(Character.valueOf(character));
                letterSprite.setPosition((float) (8 + (8 * i)), (float) (24 - (16 * j)));
                letterSprite.draw(game.uiBatch, 1.0f);
                i++;
                if (i > 20) {
                    i = 0;
                    j++;
                }
                k++;
            }
        }
    }
}
